<template>
  <div>
    <div>我是一个登录页面</div>
    <div>用户名： <input placeholder="请输入用户名" v-model="uname" /></div>
    <div>密码 <input placeholder="请输入密码" v-model="password" /></div>
    <button @click="login">立即登录</button>
    <button @click="updategroupid">修改用户的groupdid</button>
  </div>
</template>
<script setup lang="ts">
import { ref } from 'vue';
import { userLogin, updateUserInfo } from '@/api/user';

const uname = ref<string>('');
const password = ref<string>('');

const login = async () => {
  const res = await userLogin({
    uname: uname.value,
    password: password.value,
  });
  console.log('登录的结果', res);
  // 登录成功之后记得存储 accessToken以便其他接口能使用
  window.localStorage.setItem('token', res.data.accessToken);
};

// 修改用户的groupid
const updategroupid = async () => {
  const res = await updateUserInfo(1, {
    groudid: 888,
  });
  console.log('res', res);
};
</script>
